/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.co.pas.business.view.model.list;

import java.util.LinkedList;
import java.util.List;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import za.co.pas.business.data.Company;

/**
 *
 * @author alabuschagne
 */
public class CompanyListModel implements ListModel
{

    private List<Company> companies = new LinkedList<Company>();

    @Override
    public int getSize()
    {
        return companies.size();
    }

    @Override
    public Object getElementAt(int index)
    {
        return companies.get(index);
    }

    @Override
    public void addListDataListener(ListDataListener l)
    {
    }

    @Override
    public void removeListDataListener(ListDataListener l)
    {
    }

    public void setCompanies(List<Company> c)
    {
        if (c == null)
        {
            this.companies = new LinkedList<Company>();
        }
        else
        {
            this.companies = c;
        }
    }

    public void addCompany(Company c)
    {
        this.companies.add(c);
    }
}
